<form action="/cron/change_name.php">
Transfer From Code <input type="text" id="from_code" name="from_code" value="<?php echo trim($_GET['from_code']); ?>"> To  <input type="text" id="to_code" name="to_code" value="<?php echo trim($_GET['to_code']); ?>">
<input type="hidden" name="transfer" value="1">
<br>
<input type='submit' name='submit' value="Transfer" />
</form>

<?php 
if($_GET['transfer']=='1'){
set_time_limit(0);
$root=preg_replace('/cron$/', '', dirname(__FILE__));

require_once($root."inc.config.php");

require_once($root."initialize.php");

if(($db_msg=cron_initialize()) !== true){

	print_r("Connection error");

}else{ 
	
	$from = trim($_GET['from_code']);
	$to = trim($_GET['to_code']);
	if(strlen($from)<>6){
		print_r("Invalid Transfer From Code");
	}elseif(strlen($to)<>6){
		print_r("Invalid Transfer To Code");
	}else{

		$db=$vars["db"];

		$f = @mysql_num_rows($result_from=mysql_query("SELECT id, name, ic, code, remark FROM gg_users WHERE code=".$from));
		
		if($f<=0){
			print_r("Invalid Transfer From Code");
		}else{
			$row_from = mysql_fetch_assoc($result_from);
			mysql_free_result($result_from);

			if(trim($row_from['remark'])<>""){
				print_r($from." transfer before, please call admin for re-transfer. Remark:".$row_from['remark']);
			}else{
				$t = @mysql_num_rows($result_to=mysql_query("SELECT id, name, ic, code FROM gg_users WHERE code=".$to));
		
				if($t<=0){
					print_r("Invalid Transfer To Code");
				}else{
					$row_to = mysql_fetch_assoc($result_to);
					mysql_free_result($result_to);

					$sql = "UPDATE gg_users SET name='".$row_to['name']."', ic='".$row_to['ic']."', remark='amend date ".date('Y-m-d')."\nname: ".$row_from['name']."\nic: ".$row_from['ic']."' WHERE id=".$row_from['id'];
					
					if(mysql_query($sql))
						print_r("Transfer from ".$row_from['code']." to ".$row_to['code']." complete");
					else
						print_r("Transfer error, please call admin");
				}

			}
		}
	}
}
}
?>
<br><hr><br>
<form action="/cron/recalc_share.php">
<input type='submit' name='submit' value="Recalculate Share Report" />
</form>